defmodule StringSeries do
  @doc """
  Given a string `s` and a positive integer `size`, return all substrings
  of that size. If `size` is greater than the length of `s`, or less than 1,
  return an empty list.
  """
  @spec slices(s :: String.t(), size :: integer) :: list(String.t())
  def slices(s, size) do
    #IO.inspect size
    #IO.inspect  String.length(s)
    cond do
      size < 0 -> []
      size > String.length(s) -> []
      size == String.length(s) -> [s]
      true  -> split_by_step(s, size)
    end
  end

  defp split_by_step(s, size) do
    0..(String.length(s) - size)
      #|> Enum.map & IO.inspect &1
      |> Enum.map & String.slice(s, &1, size)
  end
end


